# name : proc lifereg: fits parametric survival models
# key : lifereg.
# key : cox.reg.weibull.
# key : cox.reg.dist.
# contributor: Shuguang Sun
# --
* ODS SELECT ModelInfo FitStatistics FitStatisticsUL ConvergenceStatus Type3Analysis ParameterEstimates CovB;
ods output ParameterEstimates = ${7:mod}_parame;
ods output covB = $7_covb;
proc lifereg data = ${1:dtin} plots=probplot;
model ${2:aval} * ${3:cnsr} (0) = ${4:x} /covb distribution = ${5:$$(yas/choose-value '("WEIBULL" "EXPONENTIAL" "LNORMAL" "LLOGISTIC" "NORMAL" "LOGISTIC" "GAMMA"))};
output out=${6:quant} predicted=perc quantiles=0.5 STD_ERR=stderr XBETA=xbeta;
probplot ppout npintervals=simul;
inset;
run;

proc sort data=$6 out=$6 nodupkey;
  by _prob_;
run;

data $6;
  set $6;
  lcl95 = perc + quantile('NORMAL', 0.05/2) * stderr;
  ucl95 = perc + quantile('NORMAL', 1 - 0.05/2) * stderr;
run;

proc print data = $6 noobs;
  var _prob_ xbeta perc stderr lcl95 ucl95;
run;